package myClient.command;

import lombok.Data;
import org.springframework.stereotype.Service;

import java.util.Scanner;

/**
 * <pre>
 * 登录命令的信息收集类
 * 负责收集用户在控制台输入的用户ID和密码
 * </pre>
 */

@Data
@Service("LoginConsoleCommand")
public class LoginConsoleCommand implements BaseCommand {

    public static final String KEY = "1";
    private String userName;
    private String passWord;

    @Override
    public String getKey() {
        return KEY;
    }

    @Override
    public String getTip() {
        return "登录";
    }

    @Override
    public void exec(Scanner scanner) {

        System.out.println("请输入用户消息(id@password) ");
        String[] info;
        while (true) {
            String input = scanner.next();
            info = input.split("@");
            if (info.length != 2) {
                System.out.println("请按照格式输入(id@password) : ");
            } else {
                break;
            }
        }
        userName = info[0];
        passWord = info[1];
    }

}
